<?php
require_once "checklogin.php";
require_once "../lib/MySQLDB.class.php";
date_default_timezone_set("PRC");
$db=MySQLDB::getInstance();
    if (!empty($_POST)) {
        $data = $_POST;
        $data['newsPicKey'] = $data['newsPicUrl'] ? 1 : '';
        unset($data['imgfile']);
        $data["newsID"] = $_GET["newsID"];
        $sql = "update newsinfo set newsCID=?,newsTitle=?,newsKeyWord=?,newsDesc=?,newsRemark=?,newsEditor=?,newsDate=?,
                newsPicUrl=?,newsContent=?,newsPicKey=? where newsID=?";
        $res=$db->query($sql,"sssssssssii",$data);
        if($res){
            layerAlert("文章修改成功！",1,"newsList.php");
        }else{
            layerAlert("文章修改失败！",5,"newsList.php");
        }
    }else{
        $data['newsID']=$_GET['newsID'];
        $sql="select * from newsinfo where  newsID=?";
        $row=$db->fetchRow($sql,'i',$data);
        $sql="select * from category";
        $rows=$db->fetchAll($sql);
        $cateArr=getSubTree($rows,0,0);
        require_once "view/newsEdit.html";
    }
